import com.beans.*;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * \* Created with IntelliJ IDEA.
 * \* User: Administrator
 * \* Date: 2022/7/3
 * \* Time: 16:22
 * \* To change this template use File | Settings | File Templates.
 * \* Description:
 * \
 */
public class App {
    public static void main(String[] args) {
        // 1.先得到上下文对象
        ApplicationContext context = new ClassPathXmlApplicationContext("spring-config.xml");

        BeanScopd1 beanScopd1 = context.getBean(BeanScopd1.class);
        User user1 = beanScopd1.getUser();
        System.out.println("BeanScopd1:"+user1);

        BeanScopd2 beanScopd2 = context.getBean(BeanScopd2.class);
        User user2 = beanScopd2.getUser();
        System.out.println("BeanScopd2:" + user2);


//        UserController4 userController4 = context.getBean(UserController4.class);
//        userController4.sayHi();

//        UserController3 userController3 = context.getBean(UserController3.class);
//        userController3.sayHi();

//        UserController2 userController2 = context.getBean(UserController2.class);
//        userController2.sayhi();

//        UserController controller = context.getBean(UserController.class);
//        controller.sayHi();

//        User user = context.getBean("user1", User.class);
//   //     User user = context.getBean(User.class);
//        System.out.println(user);


//        // 2.得到 bean
//        UserController controller = context.getBean("userController",
//                UserController.class);
//        // 3.使用 bean
//        controller.sayHi();

//        APIController apiController = context.getBean("APIController",
//                APIController.class);
//        apiController.sayHi();


//        UserService userService = context.getBean(UserService.class);
//        userService.sayHi();

//        UserRepository repository = context.getBean(UserRepository.class);
//        repository.sayHi();

//        UserConfig config = context.getBean(UserConfig.class);
//        config.sayHi();

//        UserComponent component = context.getBean(UserComponent.class);
//        component.sayHi();


    }
}

